<?php
/**
 * 跃飞科技版权所有 @2017
 * Date: 2017/4/25
 * Time: 15:37
 */
namespace app\home\controller;

use app\home\model\Article;
use think\Controller;
use think\Db;

class News extends Controller
{
    public function index($id = '')
    {
        $articleModel = new Article();
        $data = $articleModel->search($id);
        $data['articleCat'] = Db::name('article_cat')->select();
        $data['meta'] = Db::name('article_cat')->field('keywords,cat_desc')->find($id);
        return $this->fetch('',$data);
    }

    public function detail($id)
    {
        $data['article'] = Db::name('article')->find($id);
        $articleModel = new Article();
        $data['cat_name'] =$articleModel->getType($id);
        $data['recommend'] = Db::name('article')->order('add_time desc')->limit(4)->select();
        $data['pre_id'] = Db::name('article')->where("article_id < $id")->max('article_id')?:$id;
        $data['next_id'] = Db::name('article')->where("article_id > $id")->min('article_id')?:$id;
        return $this->fetch('',$data);
    }
}